﻿Imports Exp.Model
Imports System.Xml


Public Class FAQ1
    Inherits BasePage

    Const MENUNAME As String = "FAQ"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
            If Session("USER") Is Nothing Then
                Response.Redirect("~/login.aspx")
            Else
                Dim objUser As REM_User = CType(Session("USER"), REM_User)

                Dim objUSV As New Exp.DATA_Service.User_Service
                If Not objUSV.isHasRight(objUser.User_ID, MENUNAME) Then
                    Session("USER") = Nothing
                    Session.Clear()
                    Response.Redirect("login.aspx")

                End If

                BindData()
            End If
        End If
    End Sub

    Protected Sub BindData()
        Dim xml As New XDocument()
        Dim path = Server.MapPath("../FAQData.xml")

        xml = XDocument.Load(path)

        Dim rows = From r In xml...<row> Select r

        Dim dt As New DataTable()
        dt.Columns.Add("id")
        dt.Columns.Add("q")
        dt.Columns.Add("a")

        For Each row In rows
            Dim r As DataRow = dt.NewRow()
            r("id") = row.Attribute("id").Value
            r("q") = row.<q>.Value
            r("a") = row.<a>.Value
            dt.Rows.Add(r)
        Next

        rptData.DataSource = dt
        rptData.DataBind()

    End Sub

End Class